﻿using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using DotNETStack.Core.Web;

namespace DotNETStack.Web.UI
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class Global : HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    "Default", // Route name
            //    "{controller}/{action}/{id}", // URL with parameters
            //    new { controller = "Home", action = "Index", id = "" } // Parameter defaults
            //    );

            // Route Home
            routes.MapRoute("Home", "", new { controller = "Home", action = "Index" });
            routes.MapRoute("About", "Home/About", new { controller = "Home", action = "About" });

            // Route Users
            routes.MapRoute("Users", "Users", new { controller = "Users", action = "Index" });

            // Route Tags
            routes.MapRoute("Tags", "Tags", new { controller = "Tags", action = "Index" });

            // Route Login
            routes.MapRoute("Login", "Account/Login", new { controller = "Account", action = "Login" });
            routes.MapRoute("Logout", "Account/Logout", new { controller = "Account", action = "Logout" });
            routes.MapRoute("Register", "Account/Register", new { controller = "Account", action = "Register" });

            // Route Questions
            routes.MapRoute("Questions", "Questions", new { controller = "Questions", action = "Index" });
            routes.MapRoute("QuestionsByTags", "Questions/Tagged/{tagName}", new { controller = "Questions", action = "Tagged", tagName = "" });
            routes.MapRoute("QuestionDetails", "Questions/{id}/{title}", new { controller = "Questions", action = "Detail", id = "", title = "" });
        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}